#include <bits/stdc++.h>
using namespace std;
int t, n, a[200010], r;
bitset<200010>b;

int e() {
	vector<int>c[2];
	for (int i = 1; i <= n; i++)
		c[b[i]].push_back (i);
	int d = 0;
	for (int i = 1; i < c[0].size(); i++)
		if (a[c[0][i]] == a[c[0][i - 1]])
			d += a[c[0][i]];
	for (int i = 1; i < c[1].size(); i++)
		if (a[c[1][i]] == a[c[1][i - 1]])
			d += a[c[1][i]];
	return d;
}
int f (int x) {
	if (x > n) {
		return e();
	}
	b[x] = 1;
	int a = f (x + 1);
	b[x] = 0;
	return max (a, f (x + 1) );
}

int main() {
	freopen ("color.in", "r", stdin);
	freopen ("color.out", "w", stdout);
	for (scanf ("%d", &t); t--;) {
		r = 0;
		scanf ("%d", &n);
		for (int i = 1; i <= n; i++)
			scanf ("%d", a + i);
		printf ("%d\n", f (1) );
	}

	return 0;
}
